package 多线程.java;

public class Money {
    public synchronized void h(){
       int num = 10;
        String str2 = "";
        for (int i = str2.length() ; i<= 10; i--) {
            int b = num-i;

            try{
                System.out.println(Thread.currentThread().getName()+"王子虫取走了100元"+"还剩"+ 100*b+"元");
               Thread.sleep(20);
            }catch(InterruptedException e ){
                e.printStackTrace();
            }}

        }


    public static void main(String[] args) {
       Money money = new Money();
        new Thread(()->money.h()).start();
        new Thread(()->money.h()).start();
        money.h();
}}
